package com.youngjun.common.pojo.domain.support;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.dozer.DozerBeanMapperBuilder;
import org.dozer.Mapper;

import java.sql.Timestamp;

/**
 * @author YoungJun
 */
public class BaseDO<T> {

    /**
     * DTO to DO
     *
     * @return
     */
    @JsonIgnore
    public Mapper getDOMapper() {
        return DozerBeanMapperBuilder.create().build();
    }

    public T mapFrom(Object src){
        return mapFrom(src, getDOMapper());
    }

    public T mapFrom(Object src, Mapper mapper){
        if (src != null){
            mapper.map(src, this);
        }
        return (T) this;
    }
}